<?php
/* 定义属性 */
define ("CONfilename", "./config/set.php");
define ("DDUDB","./class/db.class.php");
define ("LOADINDEX","./class/load.class.php");
define ("PLUIN", "/plu-in/");//以后调用plu-in里的插件
/* 為系統作配置準備，方便以後系統引用數據庫 */
session_start();
require_once(CONfilename);/*讀設置*/
require_once(DDUDB);/* 載入數據庫模塊 */
require_once(LOADINDEX);/* 載入引導模塊 */

/* 配置屬性 */
$tab = 1;
$ajax = false;
$returnajaxcontent ="";
/*下面建立數據連接，添加數據庫模塊到變量，使db變量可以直接控制sql。  */
$db = new CDB();
$MEMBER = new member();
$XD = new xiadan();
$MA = new mainaction();
$GD = new gdcl();
$QC = new qccl();
$ROOT = new root();
if (!is_selog()){
	$now_user = '';
}else {
	$now_user = $_SESSION['uid'];
}
//这个页面首先判断用户是否正确登录，如未登录，就转到登录页面。
/* 方法開始 */
$ROOT->InitGlobalRoot($now_user);
/* 方法結束 */
/* 收到信息 */
if (empty($_GET['action'])) {
	$action = '';
}else {
	$action = $_GET['action'];
	if (empty($_GET['value'])) {
		$value = '';
	}else {
		$value = $_GET['value'];
	}
	/* 操作判斷 */
	switch ($action){
		case 'logout':
			unset($_SESSION['uid']);
			break;
		case 'changetab':
			$tab = $value;
			break;
		case 'chekwaitorder':
			if ($ROOT->cicwo($_SESSION['uid'])==True){
				$GD->chekwaitorder();
			}else{
				$ajax=true;
				$ROOT->stoproot();
				$returnajaxcontent = $ROOT->rooterrorhtml();
			}
			break;
		case 'chekwaitjh':
			$GD->chekwaitjh();
			break;
		case 'chekngorder':
			if ($ROOT->cicngo($_SESSION['uid'])==True){
				$GD->chekngorder();
			}else{
				$ajax=true;
				$ROOT->stoproot();
				$returnajaxcontent = $ROOT->rooterrorhtml();
			}
			break;
		case 'startmenu':
			$ajax=true;
			$returnajaxcontent = member::getstartmenu($_SESSION['uid']);
			break;
		case 'getlnf':
			$ajax=true;
			$returnajaxcontent = mainaction::getleftnavfloder();
			break;
		case 'getckb':
			$ajax=true;
			$returnajaxcontent = mainaction::getckbifm();
			break;
		case 'yclp':
			$ajax=true;
			$returnajaxcontent = mainaction::getyclplance($value,$_POST);
			break;
		case 'fastnewgd':
			$ajax=true;
			include './temp/plu-in/xiadan.php';
			break;
		case 'hotline':
			$ajax = true;
			include './tpl/tpl.hotline.html';
			break;
		case 'chaxiaojie':
			# 查询小结
			$ajax = true;
			if (isset($_GET['value'])) {
				$returnajaxcontent = mainaction::searchxiaojie($_GET['value']);
			}else{
				$returnajaxcontent = mainaction::searchxiaojie();
			}
			break;
	}
}
if($_POST)
{
	switch ($action) {
		case 'xiadan':
			$ajax=true;
			if($XD->submitGD($_POST)){
				
				$returnajaxcontent = '<script>alert("操作成功!");
				cleantextarea();</script>';
			}else{
				$returnajaxcontent = '<script>alert("操作不成功!");</script>';
				}
			break;
		case 'xiaycldan':
			$ajax=true;
			if($XD->submitYCL($_POST)){
				$returnajaxcontent = '<script>alert("操作成功!");
				cleantextarea();</script>';
			}else{
				$returnajaxcontent = '<script>alert("操作不成功!");</script>';
			}
			break;
		case 'lit':
			$QC->submitLIT($_POST);
			$tab = 5;
			break;
		case 'chekgdlb':
			$GD->chekgdlb($_POST['starttime'], $_POST['endtime'],$_POST['lxnumber']);
			break;
		case 'chekjhlb':
			$GD->chekjhlb($_POST['starttime'], $_POST['endtime'],$_POST['lxnumber']);
			break;
		case 'chekqclb':
			$QC->chekqclb($_POST['starttime'], $_POST['endtime'],$_POST['lxnumber']);
			break;
		case 'addcomrec':
			$ajax = true;
			mainaction::newtelrec($_POST);
			break;
	}
}
/* 收到信息完成 */
/* 開始渲染頁面 */
if (file_exists(CONfilename)) {
	include CONfilename;
	if ($lock==true){
		require './temp/lock.php';
	}else {
		if($ajax==true){
			echo $returnajaxcontent;
		}else{
			require './temp/temp_html.php';
		}
	}
} else {
    require_once './config/in_config.php';
}



